@echo off

echo ==========
echo start gen
echo ==========


set ip=%1%

for /f "tokens=1-3 delims=-/ " %%1 in ("%date%") do set ddd=%%1%%2%%3
for /f "tokens=1-4 delims=.: " %%1 in ("%time%") do set tttt=%%1%%2%%3%%4
set DT=%ddd%%tttt%

rem set saveDir=%~dp0%DT%
set saveDir=%~dp0%ip%
mkdir %saveDir%
echo %saveDir%


keytool -validity 36500 -genkey -v -alias server -keyalg RSA -keystore %saveDir%\server.keystore -dname "CN=%ip%,OU=sss,O=sss,L=BeiJing,ST=BeiJing,c=cn" -storepass 123456 -keypass 123456 -ext san=ip:%ip%

keytool -export -v -alias server -keystore %saveDir%\server.keystore -storepass 123456 -rfc -file %saveDir%\server.cer
